﻿//using CoreCms.Net.Bz;
//using CoreCms.Net.Bz.Common.Response;
//using CoreCms.Net.Bz.Filter;
//using CoreCms.Net.Model.FromBody;
//using CoreCms.Net.Model.ViewModels.Basics;

//using Microsoft.AspNetCore.Authorization;
//using Microsoft.AspNetCore.Hosting;
//using Microsoft.AspNetCore.Mvc;
//using Silky.Core.Extensions;
//using System.ComponentModel;
//using System.Linq;
//using System.Threading.Tasks;

//namespace CoreCms.Net.Web.Admin.Controllers.System
//{
//    /// <summary>
//    ///     定时Quartz任务日志
//    /// </summary>
//    [Description("定时Quartz任务日志")]
//    [Route("api/[controller]/[action]")]
//    [ApiController]
//    [RequiredErrorForAdmin]
//    [Authorize(Permissions.Name)]
//    public class SysQuartzManagerController : ControllerBase
//    {
//        private readonly IWebHostEnvironment _webHostEnvironment;
//        private readonly IQzJobService _qzJobService;

//        /// <summary>
//        ///     构造函数
//        /// </summary>
//        public SysQuartzManagerController(IWebHostEnvironment webHostEnvironment
//            , IQzJobService qzJobService
//        )
//        {
//            _webHostEnvironment = webHostEnvironment;
//            _qzJobService = qzJobService;
//        }

//        #region 获取列表============================================================

//        // POST: Api/SysQuartzManager/GetPageList
//        /// <summary>
//        ///     获取列表
//        /// </summary>
//        /// <returns></returns>
//        [HttpPost]
//        [Description("获取列表")]
//        public async Task<AdminUiCallBack> GetPageList()
//        {
//            var jm = new AdminUiCallBack();
//            var pageCurrent = Request.Form["page"].FirstOrDefault().ObjectToInt(0);
//            var pageSize = Request.Form["limit"].FirstOrDefault().ObjectToInt(30);
//            var jobName = Request.Form["jobName"].FirstOrDefault();
//            var jobGroup = Request.Form["jobGroup"].FirstOrDefault();
//            var myList = await _qzJobService.GetJobList(new JobSearchRequest() { JobName = jobName, JobGroup = jobGroup });
//            var resultList = new PageList<JobResponse>(myList.ToList(), pageCurrent == 0 ? 0 : pageCurrent - 1, pageSize);
//            //返回数据
//            jm.data = resultList;
//            jm.code = 0;
//            jm.count = resultList.TotalCount;
//            jm.msg = "数据调用成功!";
//            return jm;
//        }

//        #endregion 获取列表============================================================

//        #region 首页数据============================================================

//        // POST: Api/SysQuartzManager/GetIndex
//        /// <summary>
//        ///     首页数据
//        /// </summary>
//        /// <returns></returns>
//        [HttpPost]
//        [Description("首页数据")]
//        public AdminUiCallBack GetIndex()
//        {
//            //返回数据
//            var jm = new AdminUiCallBack { code = 0 };
//            return jm;
//        }

//        #endregion 首页数据============================================================

//        // POST: Api/SysQuartzManager/QuartzTrigger
//        /// <summary>
//        ///     触发
//        /// </summary>
//        /// <returns></returns>
//        [HttpPost]
//        [Description("触发")]
//        public async Task<AdminUiCallBack> QuartzTrigger([FromBody] FQuartzTrigger model)
//        {
//            var jm = new AdminUiCallBack();

//            await _qzJobService.Trigger(model.jobName, model.jobGroup);
//            jm.code = 0;
//            jm.msg = "成功";

//            return jm;
//        }

//        // POST: Api/SysQuartzManager/QuartzPause
//        /// <summary>
//        ///     暂停
//        /// </summary>
//        /// <returns></returns>
//        [HttpPost]
//        [Description("暂停")]
//        public async Task<AdminUiCallBack> QuartzPause([FromBody] FQuartzTrigger model)
//        {
//            var jm = new AdminUiCallBack();

//            await _qzJobService.Pause(model.jobName, model.jobGroup);
//            jm.code = 0;
//            jm.msg = "成功";

//            return jm;
//        }

//        // POST: Api/SysQuartzManager/QuartzResume
//        /// <summary>
//        ///     恢复
//        /// </summary>
//        /// <returns></returns>
//        [HttpPost]
//        [Description("恢复")]
//        public async Task<AdminUiCallBack> QuartzResume([FromBody] FQuartzTrigger model)
//        {
//            var jm = new AdminUiCallBack();

//            await _qzJobService.Resume(model.jobName, model.jobGroup);
//            jm.code = 0;
//            jm.msg = "成功";

//            return jm;
//        }

//        // POST: Api/SysQuartzManager/QuartzDelete
//        /// <summary>
//        ///     删除
//        /// </summary>
//        /// <returns></returns>
//        [HttpPost]
//        [Description("删除")]
//        public async Task<AdminUiCallBack> QuartzDelete([FromBody] FQuartzTrigger model)
//        {
//            var jm = new AdminUiCallBack();

//            await _qzJobService.DeleteJob(model.jobName, model.jobGroup);
//            jm.code = 0;
//            jm.msg = "成功";

//            return jm;
//        }
//    }
//}